FROM golang:latest

# 设置 Go 代理
ENV GOPROXY=https://goproxy.cn

# 安装 kubectl
RUN apt-get update && \
    apt-get install -y apt-transport-https gnupg2 && \
    curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add - && \
    echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list && \
    apt-get update && \
    apt-get install -y kubectl && \
    rm -rf /var/lib/apt/lists/*

# 安装 Kubebuilder
ENV KUBEBUILDER_VERSION=3.1.0
RUN curl -L -O https://kubernetes-release.pek3b.qingstor.com/kubebuilder/v${KUBEBUILDER_VERSION}/kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64.tar.gz && \
    tar -zxvf kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64.tar.gz && \
    mv kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64 /usr/local/kubebuilder

ENV PATH=$PATH:/usr/local/kubebuilder/bin

WORKDIR /go/src/app

CMD ["sleep", "infinity"]